<template>
	<view style="height: 500rpx;"><qiun-data-charts type="column" :chartData="chartData" /></view>
</template>

<script>
export default {
	props: {
		atd: {
			type: Object | Array,
			default() {
				return [];
			}
		}
	},
	data() {
		return {
			chartData: {}
		};
	},
	mounted() {
		this.init();
	},
	watch: {
		atd(n) {
			this.init();
		}
	},
	methods: {
		init() {
			if (this.atd && this.atd.length > 0) {
				this.chartData = {
					categories: this.atd.map(e => {
						return e.date;
					}),
					series: [
						{
							name: '实名制进场人数',
							data: this.atd.map(e => {
								return e.staffs;
							})
						},
						{
							name: '考勤总人数',
							data: this.atd.map(e => {
								return e.atdStaffs;
							})
						}
					]
				};
			} else {
				this.chartData = {};
				console.error('首页统计图', '没有工人分布数据');
			}
		}
	}
};
</script>

<style></style>
